package com.tengju.bff.interfaces.covercharge.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.math.BigDecimal;

/**
 * @author: 李大仙
 * @date: 2021/7/14 2:46 下午
 */
@Component
@Slf4j
public class MoneyHelper {

    @Value("${service.fee.ratio.limit}")
    private String serviceFeeRatioLimit;

    @Value("${service.fee.ratio.small}")
    private String serviceFeeRatioSmall;

    @Value("${service.fee.ratio.large}")
    private String serviceFeeRatioLarge;

    private static MoneyHelper instance;

    public static MoneyHelper getInstance() {
        return MoneyHelper.instance;
    }

    @PostConstruct
    public void init() {
        setInstance(this);
    }

    private static void setInstance(MoneyHelper instance) {
        MoneyHelper.instance = instance;
    }

    public BigDecimal getServiceFeeRatioLimit() {
        return new BigDecimal(serviceFeeRatioLimit);
    }

    public BigDecimal getServiceFeeRatioSmall() {
        return new BigDecimal(serviceFeeRatioSmall);
    }

    public BigDecimal getServiceFeeRatioLarge() {
        return new BigDecimal(serviceFeeRatioLarge);
    }
}
